package com.java.controller;

import com.alibaba.fastjson.JSONObject;
import com.java.sevice.impl.TransferService;
import com.java.utils.HttpParamUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
@RequestMapping(value = "/transfer")
@Api(tags = "")
public class TransferController {
    @Autowired
    private TransferService transferService;

    /**
     * 提供增加金额准备接口
     */
    @PostMapping(value = "/doTransfer")
    public Object doTransfer(@RequestBody String param) throws Exception {
        JSONObject json = HttpParamUtil.paramToJson(param);
        Long accountId = json.getLong("accountId");
        BigDecimal amount = json.getBigDecimal("amount");
        return this.transferService.doTransfer(accountId, amount);
    }
}
